Open
Conversation
added 11 commits
December 1, 2017 11:29
Adds support for using a provided stored proc as procedure name instead of default :sp_execute
|
This is a good addition to functionality. What's the hold-up on the acceptance? Anything I can do to help? |
|
@drowzy, this is pretty close, are you going to pick it back up? |
Author
|
It’s been a long time! I can try to rebase and fix conflicts, when I get the time. |
|
I think I can make this return multiple result sets too. I don't know how common needing that functionality is. The company I'm currently at has dbas that maintain their own layer of sps as an api |
Author
|
@Deathklok-97 Oh if you already applied my changes to an up to date fork, then go for it! You can just reference and I'll close this PR. I haven't been working with SQL server for a long time and don't remember much from this implementation either so :). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR adds support for Table Valued Parameters. It's functional but can be considered a WIP. I would like some feedback and suggestions before I progress further.
Most functionality required for tvp is already present, there are few additions required:
The spec lists type restrictions and the corresponding replacement types. Implemented here.
As the columns does not include a value, the attributes can not be calculated when encoding the column. Due to this the attributes needs to be provided in the
optspart of the column. For most types, encoding usingencode_<type>_typefunction works with a%Paramter{value: nil}. With the exception of varchar & varbinary (probably more but I haven't encountered them yet).I've added a new function for running stored procedures https://github.com/drowzy/tds/blob/b1991bce00d50131b83b034cb2bddfba547470e6/lib/tds.ex#L21
as I couldn't get it to work using
Tds.query. It passes the statement inoptsso that it can be used in ahandle_executecallback (This is a bit dirty and I would like a suggestion for a cleaner solution), as it is required for the rcp name to be that of the SP you intend to run. This is how other tds libraries does I believeAlso the only parameters passed is the ones specified as input (i.e no
@handle).Known shortcomings
encode_tvp_typedoes not take database & table name into consideration. According to the spec:"f the TVP is a parameter to a stored procedure or function where parameter metadata is available on the server side, the client can send all zero-length strings for TVP_TYPENAME".
No TVP_ORDER_UNIQUE
All types not thoroughly tested.
uniqueidentifiersdoes not seem to be parsed to auuidwhen receiving a result.Feedback is very much appreciated.